<template>
	<view>
		<view class="content" v-if="!dataList || dataList.length < 1">
			<u-empty text="所谓伊喵，干饭第一" mode="list"></u-empty>
		</view>
		<view v-else style="padding: 3%;">
			<view v-for="(year,yearIndex) in dataList" :key="yearIndex">
				<text style="font-size: 28px;">
					{{year.key}}年
				</text>
				<view v-for="(month,monthIndex) in year.botEatingOwnList" :key="monthIndex">
					<view style="margin: 5% 0;">
						<text style="font-size: 28px;">
							{{month.key}}月
						</text>
						<view style="display: flex;flex-wrap: wrap; ">
							<view style="display: flex;margin: 0% 2% 2% 0%;"
								v-for="(image,fileIndex) in month.sysFileInfos" :key="image.id"
								@click="openImage(month.sysFileInfos,fileIndex)">
								<u-image :src="image.fileUrl" mode="aspectFill" width="220rpx" height="220rpx"
									:lazy-load="true"><u-loading slot="loading"></u-loading></u-image>
							</view>
						</view>
					</view>
				</view>
			</view>
			<u-loadmore status="nomore" />
		</view>
	</view>
</template>

<script>
	import {
		getEatingOwnList,
	} from '@/api/bot/eating'
	export default {
		data() {
			return {
				query: {
					pageNum: 1,
					pageSize: 10,
					ownData: true,
					groupId: ''
				},
				dataList: [],
				maxContentLength: 30
			}
		},
		onLoad() {
			uni.getStorage({
				key: 'groupIdByIndex',
				success: (res) => {
					let data = JSON.parse(res.data);
					this.query.groupId = data.id;
					this.getEatingOwnList()
				}
			});
		},
		onPullDownRefresh() {
			this.getEatingOwnList()
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 1500)
		},
		methods: {
			getEatingOwnList() {
				uni.showLoading({
					title: '加载中...'
				})
				getEatingOwnList(this.query).then(res => {
					this.dataList = res.rows;
					uni.hideLoading()
				}).catch(error => {
					uni.hideLoading()
				})
			},
			openImage(sysFileInfos, fileIndex) {
				let content = sysFileInfos.map(item => item.fileUrl)
				uni.previewImage({
					urls: content,
					current: fileIndex
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.u-card-wrap {
		background-color: $u-bg-color;
		padding: 1px;
	}

	.u-body-item {
		font-size: 32rpx;
		color: #333;
		padding: 20rpx 10rpx;
	}

	.u-body-item image {
		width: 120rpx;
		flex: 0 0 120rpx;
		height: 120rpx;
		border-radius: 8rpx;
		margin-left: 12rpx;
	}

	.content {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 10%;
		overflow-y: true;
	}

	.content {
		height: 100%;
	}

	.scroll scroll-view {
		height: 100%;
	}
</style>